//package com.zhang.common.batch;
//
//import org.springframework.batch.core.Step;
//import org.springframework.batch.core.configuration.annotation.JobBuilderFactory;
//import org.springframework.batch.core.configuration.annotation.StepBuilderFactory;
//import org.springframework.batch.core.partition.PartitionHandler;
//import org.springframework.batch.core.partition.support.TaskExecutorPartitionHandler;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.context.annotation.Bean;
//import org.springframework.core.task.SimpleAsyncTaskExecutor;
//import org.springframework.stereotype.Component;
//
///**
// * 任务配置基类
// *
// * @author zhangxin
// * @date 2020-12-21 09:29:00
// */
//@Component
//public class BaseConfiguration {
//    @Autowired
//    protected JobBuilderFactory jobBuilderFactory;
//    @Autowired
//    protected StepBuilderFactory stepBuilderFactory;
//
//    /**
//     * 分区处理方法
//     * 例：
//     * @Bean
//     *     public Step xxPartitionStep() {
//     *         return stepBuilderFactory.get("xxStep")
//     *                 .partitioner(xxxMainStep().getName(), xxxPartitioner)
//     *                 .partitionHandler(partitionHandler(config, xxxMainStep(), new SimpleAsyncTaskExecutor()))
//     *                 .build();
//     *
//     *     }
//     *
//     * @param config
//     * @param step
//     * @return
//     */
//    public PartitionHandler partitionHandler(BaseConfig config, Step step, SimpleAsyncTaskExecutor executor) {
//        TaskExecutorPartitionHandler handler = new TaskExecutorPartitionHandler();
//        handler.setGridSize(config.getGridSize());
//        handler.setTaskExecutor(executor);
//        handler.setStep(step);
//        try {
//            handler.afterPropertiesSet();
//        } catch (Exception e) {
//            e.printStackTrace();
//        }
//        return handler;
//    }
//
//    @Bean
//    public SimpleAsyncTaskExecutor taskExecutor() {
//        return new SimpleAsyncTaskExecutor();
//    }
//}
